package com.biyeshengjiuye.service.impl;

import com.biyeshengjiuye.dao.EnterpriseMapper;
import com.biyeshengjiuye.entity.Enterprise;
import com.biyeshengjiuye.service.EnterpriseService;
import com.biyeshengjiuye.utils.PasswordUtil;
import com.biyeshengjiuye.utils.SystemConstant;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class EnterpriseServiceImpl implements EnterpriseService {

    @Resource
    private EnterpriseMapper enterpriseMapper;

    public Enterprise login(String loginId, String loginPwd) {
        Enterprise enterprise = enterpriseMapper.findEnterpriseById(loginId);
        if (enterprise != null){
            String newPassword = PasswordUtil.md5(loginPwd,loginId, SystemConstant.PASSWORD_COUNT);
            if (newPassword.equals(enterprise.getE_password())){
                return enterprise;
            }
        }
        return null;
    }

    public int findById(String e_id) {
        return 0;
    }
}
